package com.liancheng.smarthome.module;

import android.content.Context;
import android.databinding.ViewDataBinding;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.liancheng.smarthome.base.adapter.AdapterClickListener;
import com.liancheng.smarthome.base.adapter.SuperBaseAdapter;
import com.liancheng.smarthome.bean.ListBeans;
import com.liancheng.smarthome.utils.common.ToastUtil;

import java.util.List;

/**
 * 简历list的列表页面
 */
public class ForListAdapter extends SuperBaseAdapter<ListBeans> {
    public ForListAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }

    @Override
    public AdapterClickListener getClickListener(ListBeans item, int postion, ViewDataBinding binding) {
        return new QClickListener(item, postion, binding);
    }

    // 点击事件逻辑处理
    public class QClickListener extends AdapterClickListener<ListBeans> {
        private ListBeans item;
        private int postion;
        private ViewDataBinding binding; // 可以直接使用binding.获取要控制的组件,方便灵活，不用亦不影响
        public QClickListener(ListBeans item, int postion, ViewDataBinding binding) {
            this.item = item;
            this.postion = postion;
            this.binding =   binding;
        }

        @Override
        public void onItemClickListener(View v, int position,ListBeans listBeans) {
            listBeans.firstName.set("点击了我");
            ToastUtil.showShort("第"+postion+"个-->"+item.lastName.get() + ";" +listBeans.firstName.get());
        }

        public void showToast(View v,ListBeans listBeans){
//            + binding.btnTest.getText().toString ()/
            listBeans.firstName.set("点击了我");
            ToastUtil.showShort("第"+postion+"个-->"+item.lastName.get() + ";" +listBeans.firstName.get());
        }
    }

}
